package com.lei.array;

/**
 * @author: leiGer
 * @Date: 2021/07/07
 * @Time: 20:50
 */
public class LeetCode704 {
    public int search(int[] nums,int target){
        int n = nums.length;
        int left = 0;
        int right = n-1;
        while (left <= right){
            int mid = left + (right - left)/2;
            if(target < nums[mid]){
                right = mid - 1;
            }else if(target > nums[mid]){
                left = mid + 1;
            }else{
                return mid;
            }

        }
        return -1;
    }

    public static void main(String[] args) {
        int []arr = new int []{-1,3,6,25,65,96};
        int target = 25;
        LeetCode704 leetCode704 = new LeetCode704();
        System.out.println(leetCode704.search(arr, target));
    }
}
